pp108 : Implementing Java Management Extensions (JMX) in Applications

Implementing Java Management Extensions (JMX) in Applications

This topic describes the implementation of Java Management Extensions in applications.

The concept of "management interface" draws its inference from an application resource that provides some value to the user. Application resource here refers to the 'business component' within an application or an infrastructure component such as a cache or queue or the entire application itself. Application resource in the context of JMX encapsulates only those resources that must be managed.
Each such resource that requires management would need to provide a management interface. The attributes and operations as exposed by a management interface must be monitored and controlled by a management application.
The same concept of management interface can be applied to Process Platform that supports operational management through JMX (Java Management Extensions). The purpose of this management interface could involve collecting performance figures from different components of the Process Platform, reading the settings of those components and so on.
This management interface comes as a handy tool to the Process Platform application developers for developing applications that can be managed and monitored from any management console that supports JMX.

The above definition can be substantiated using an example of a queue that needs to be managed in an application. Logically speaking, a queue is temporarily used to store 'logical units of work' until it is taken away from the queue for further processing. This is done asynchronously through a multithreaded design so the queue must also be thread-safe. Suppose the application is characterized by a single supplier thread and a single consumer thread. The queue is assumed to be thread-safe so that the user or the supplier would need to wait until an item is added to the queue if it is empty. On similar lines, the consumer that picks the items from the queue for further processing would need to wait to remove an item is the queue is empty.

The next step would be to identify some specific information that can assist in monitoring the application. In the context of queue explained above, the significant information that could require monitoring is the time duration for which a supplier would need to wait to add an item to the queue because the queue is full and a consumer would need to wait to remove an item from the queue because the queue is empty.Therefore, this information can be exposed as two attributes on the management interface of the queue.

This section contains code samples and best practices for: